# Maintainer: umarcor <unai.martinezcorral@ehu.eus>

_realname=openFPGALoader
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=0.5.0
pkgrel=2
pkgdesc="openFPGALoader: universal utility for programming FPGA (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32')
url="https://github.com/trabucayre/openFPGALoader"
license=('Apache-2.0')
groups=("${MINGW_PACKAGE_PREFIX}-eda")
depends=("${MINGW_PACKAGE_PREFIX}-libftdi")
makedepends=(
  "${MINGW_PACKAGE_PREFIX}-gcc"
  "${MINGW_PACKAGE_PREFIX}-cmake"
)

source=("${_realname}::https://codeload.github.com/trabucayre/openFPGALoader/tar.gz/v${pkgver}")
sha256sums=('39c9686bdfcfa96b6bb1d8b37a8a53732372c16cda562036abe9930b61b29e97')

build() {
  cd "${srcdir}/${_realname}-${pkgver}"
  mkdir build
  cd build
  MSYS2_ARG_CONV_EXCL=- cmake \
    -G "MSYS Makefiles" \
    -DCMAKE_INSTALL_PREFIX="${MINGW_PREFIX}" \
    ../
  cmake --build .
}

check() {
  "${srcdir}/${_realname}-${pkgver}"/build/openFPGALoader.exe --help
}

package() {
  cd "${srcdir}/${_realname}-${pkgver}"/build
  make DESTDIR="${pkgdir}" install

  _licenses="${pkgdir}${MINGW_PREFIX}/share/licenses/${_realname}"
  mkdir -p "${_licenses}"
  install -m 644 "${srcdir}/${_realname}-${pkgver}"/LICENSE "${_licenses}"
}
